/**
 * 
 */
package com.suyx.job.controller;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.util.Arrays;
import java.util.Date;
import java.util.List;
import java.util.Optional;

import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.suyx.job.config.BaiduOCR;
import com.suyx.job.config.RedisUtils;
import com.suyx.job.core.IHoldService;
import com.suyx.job.entity.EmailContent;
import com.suyx.job.entity.EmailServerInfo;
import com.suyx.job.entity.GoodsInfo;
import com.suyx.job.entity.LuaColorInfo;
import com.suyx.job.entity.PhGoodsPriceInfo;
import com.suyx.job.entity.Result;
import com.suyx.job.entity.RoleInfo;
import com.suyx.job.entity.TaskInfo;
import com.suyx.job.entity.TuInfoLog;
import com.suyx.job.job.ExecuteJob;
import com.suyx.job.service.IEmailService;
import com.suyx.job.service.IGoodsInfoService;
import com.suyx.job.service.ILuaColorInfoService;
import com.suyx.job.service.IPhGoodsPriceInfoService;
import com.suyx.job.service.IRoleInfoService;
import com.suyx.job.service.ITaskInfoService;
import com.suyx.job.service.ITuInfoLogService;
import com.suyx.job.service.area.IGoAreaService;
import com.suyx.job.service.sect.IGoToSectService;
import com.suyx.job.utils.EmailUtils;
import com.suyx.job.utils.ImagePHash;
import com.suyx.job.utils.ImageUtils;
import com.suyx.job.utils.ScreenCapture;
import com.suyx.job.utils.SpeechUtil;
import com.suyx.job.utils.SysStaticData;
import com.suyx.job.utils.SysStaticPhData;

import lombok.extern.slf4j.Slf4j;

/**
 * @author syx
 *
 */
@Slf4j
@RestController
@RequestMapping("/mhxyPhTask")
public class MhxyPhController {

	@Autowired
	private IRoleInfoService roleService;
	
	@Autowired
	private BaiduOCR baiduOCR;

	@Autowired
	protected IHoldService holdService;

	@Autowired
	private RedisUtils redisService;

	@Autowired
	private IGoodsInfoService goodsService;
	
	@Autowired
	private ITuInfoLogService tuInfoLogService;
	
	@Autowired
	private IPhGoodsPriceInfoService phGoodsPriceInfoServce;
	
	@Autowired
	private  IEmailService emailService ;
	
	@Autowired
	private ILuaColorInfoService luaColorService;
	
	@Autowired
	private ITaskInfoService taskInfoService;
	
	public <T> T getService(Class<T> t) throws Exception {
		return holdService.getServiceInstance(t);
	}

	public <T> T getService(String serviceName, Class<T> clazz) throws Exception {
		return holdService.getServiceInstance(serviceName);
	}
	
	@PostMapping("/phTask")
    public Result phTask(Integer roleId) throws Exception{
		RoleInfo roleInfo = roleService.getOne(roleId);
		boolean flag = true;
		while(true){
			Integer sectNum = (Integer) Optional.ofNullable(redisService.get(roleInfo.getRoleName())).orElse(0);
			if(sectNum >= 20){
				SpeechUtil.textToSpeech(roleInfo.getRoleName() + "今天已经设置不能跑环任务");
				log.info(roleInfo.getRoleName() + "今天已经设置不能跑环任务");
				break;
			}
			
			if(!doSmTask(roleInfo)){
				log.info("["+ roleInfo.getRoleName()+"] 跑环任务完成");
				break;
			}
		}
		
		return new Result(true,"["+ roleInfo.getRoleName()+"] 跑环任务完成");
	}


	@SuppressWarnings("unused")
	private boolean doSmTask(RoleInfo roleInfo) throws Exception {
		String device = roleInfo.getDevice();
		String roleSect = roleInfo.getRoleSect();
		String path = SysStaticData.SC_PIC_PATH + device + "\\";
		String text =  getPhTaskInfo(roleInfo,path);
		String npc = "";
		String wp = "";
		
		GoodsInfo goodsInfo = null;
		String last_text = (String) redisService.get("last_text"+roleInfo.getRoleId());
		
		//EmailServerInfo emailServerInfo = emailService.findById(1).get();
		
		if(text.equals(last_text)){
			SpeechUtil.textToSpeech(roleInfo.getRoleName() + "当前任务在重复做");
			//EmailUtils emailUtils = new EmailUtils();
			//EmailContent content = new EmailContent("跑环报警", roleInfo.getRoleName() + "当前任务在重复做："+text);
	      //  emailUtils.sendEmail(emailServerInfo, content);
			return false;
		}
		redisService.set("last_text"+roleInfo.getRoleId(), text,1800L);
		Integer kong_location = 0;
		for (String key : SysStaticPhData.NPC.keySet()) {
			if(text.indexOf(key) > -1){
				npc = key;
				break;
			}
		}
		
        for (String key : SysStaticPhData.PH_WQ_TYPE.keySet()) {
        	if(text.indexOf(key) > -1){
        		wp = key;
				break;
			}
		}
        
		log.info(roleInfo.getRoleName()+" NPC:"+npc+" WP:"+wp);
		
		if(StringUtils.isBlank(npc)){
			log.info("["+roleInfo.getRoleName()+"]找不到NPC");
			SpeechUtil.textToSpeech(roleInfo.getRoleName() + "找不到NPC");
			
			//EmailUtils emailUtils = new EmailUtils();
			//EmailContent content = new EmailContent("跑环报警", roleInfo.getRoleName() + "找不到NPC："+text);
	        //emailUtils.sendEmail(emailServerInfo, content);
			return false;
		}
		
		String npc_addr = SysStaticPhData.NPC.get(npc);
		//ca3#1#0#669&561&798&291
		String[] addr_info = npc_addr.split("#");
		String[] info = addr_info[3].split("&");
					
		
		// 寻物
		if (text.indexOf("帮") > -1 
				&& text.indexOf("找") > -1
				&& StringUtils.isNoneBlank(wp)) {
			
			wp = Optional.ofNullable(SysStaticPhData.PH_WQ_TO_CONVEN.get(wp)).orElse(wp);

			ScreenCapture.mouseClick(device, "1308 675");// # 打开包裹
			Thread.sleep(1000L);
			kong_location = getKongLocation(roleInfo.getDevice(),path,wp);
			
			if (kong_location != 99){
				goodsInfo = goodsService.findByRoleIdAndGoodsName(roleInfo.getRoleId(), wp);
				
				//取物品
				if (goodsInfo != null && kong_location != 99) {
					ScreenCapture.mouseClick(device, "715 305");// 打开ca2 2-1
					Thread.sleep(500L);
					ScreenCapture.mouseClick(device, "522 422");// 使用
					ScreenCapture.mouseClick(device, "488 421");// 长安群雄仓库
					ScreenCapture.mouseClick(device, "1156 52");// 关闭包裹
					
					String location = goodsInfo.getLocation();
					String[] doclick_c_k_info = location.split("&");
					// 点击仓库NPC
					Thread.sleep(1 * 1000L);
					ScreenCapture.mouseClick(device, "664 292");
					Thread.sleep(1 * 1000L);
					ScreenCapture.mouseClick(device, "1228 442");

					// 选择仓库中的物品
					Thread.sleep(500L);
					ScreenCapture.mouseClick(device, "344 624");
					Thread.sleep(500L);
					ScreenCapture.mouseClick(device, doclick_c_k_info[0] + " " + doclick_c_k_info[1]);
					Thread.sleep(500L);
					//ScreenCapture.mouseClick(device, doclick_c_k_info[2] + " " + doclick_c_k_info[3]);
					String[] c_k_x_y = SysStaticPhData.PH_WQ_TYPE.get(wp).split("&");
					Thread.sleep(500L);
					
					if(goodsInfo.getGoodsCode() < 222){
						ScreenCapture.mouseClick(device, doclick_c_k_info[2] + " " + doclick_c_k_info[3]);
						Thread.sleep(5 * 100L);
						ScreenCapture.mouseClick(device, c_k_x_y[0] + " " + c_k_x_y[1]);
					}else{
						int i = 0;
						while(true){
							ScreenCapture.mouseClick(device, doclick_c_k_info[2] + " " + doclick_c_k_info[3]);
							
							ScreenCapture.snapshot(device, path, "screen.png");
							Thread.sleep(5 * 100L);
							ImageUtils.cutPNG(new FileInputStream(path + "screen.png"), new FileOutputStream(path + device + ".png"), 786,
									222, 153, 42);// y52 244 307
							String text2 = baiduOCR.generalBasic(path + device + ".png");// 33 535
							text2 = Optional.ofNullable(SysStaticPhData.PH_WQ_TO_CONVEN.get(text2)).orElse(text2);
							log.info("识别仓库物品："+text2);
							if(!wp.equals(text2) || i > 5){
								break;
							}else{
								ScreenCapture.mouseClick(device, c_k_x_y[0] + " " + (Integer.valueOf(c_k_x_y[1]) + 32 * (i-1)));
								i++;
							}
							
						}
					}
					
					// 关闭仓库
					Thread.sleep(500L);
					ScreenCapture.mouseClick(device, "1152 55");
					goodsInfo.setStatus("1");
					goodsService.saveAndFlush(goodsInfo);
				} else {
					String te = roleInfo.getRoleName() + "任务物品: [" + wp + "]使用完毕";
					log.info(te);
					SpeechUtil.textToSpeech(te);
					
					//EmailUtils emailUtils = new EmailUtils();
					//EmailContent content = new EmailContent("跑环报警", te +"："+text);
			        //emailUtils.sendEmail(emailServerInfo, content);
					
					//return false;
					
					
					//先去建业
					//ScreenCapture.mouseClick(device, "1308 675");//  # 打开包裹
					ScreenCapture.mouseClick(device, "1073 224");// 打开FF 1
					ScreenCapture.mouseClick(device, "527 406");// 使用
					//建邺城
					ScreenCapture.mouseClick(device, "890 435");
					ScreenCapture.mouseClick(device, "1156 52");// 关闭包裹
					Thread.sleep(4 * 1000L);
					
					String random_x = String.format("%.0f",Math.floor(400*Math.random()));
					ScreenCapture.mouseClick(device, random_x+" 103");
					
					ScreenCapture.mouseClick(device, "1308 675");//  # 打开包裹
					
					//===============任务写入任务表============================================
					String[] c_k_x_y = SysStaticPhData.PH_WQ_TYPE.get(wp).split("&");
					
					LuaColorInfo luaCorlorInfo = luaColorService.findByWpName(wp);
					TaskInfo taskInfo = new TaskInfo();
					if(luaCorlorInfo != null ){
						if(roleInfo.getJqNo() != null){
							taskInfo.setCreateTime(new Date());
							taskInfo.setJqNo(roleInfo.getJqNo());
							taskInfo.setRoleId(String.valueOf(roleInfo.getRoleId()));
							taskInfo.setRoleName(roleInfo.getRoleName());
							taskInfo.setStatus("0");
							taskInfo.setWpType(Integer.valueOf(c_k_x_y[4]));
							taskInfo.setTaskType(2);
							taskInfo.setTaskText(text);
							taskInfo.setWpName(wp);
							// color & posandcolor & 是否从1仓库开始 &在机器上好友位置
							taskInfo.setRemark(luaCorlorInfo.getColor()+
									"&"+luaCorlorInfo.getPosandcolor()+
									"&"+luaCorlorInfo.getRemark()+
									"&"+roleInfo.getHyLoc());
							TaskInfo task = taskInfoService.findByRoleIdAndTaskText(taskInfo.getRoleId(), taskInfo.getTaskText());
							if(task ==  null){
								taskInfoService.saveAndFlush(taskInfo);
							}
						}else{
							log.info("角色没有配置机器编码信息："+roleInfo.getRoleName());
						}
					}else{
						log.info("物品没有配置LUA颜色信息："+wp);
					}
					
					//==========================================================
					while(true){
						Integer sectNum = (Integer) Optional.ofNullable(redisService.get(roleInfo.getRoleName())).orElse(0);
						if(sectNum >= 20){
							SpeechUtil.textToSpeech(roleInfo.getRoleName() + "今天已经设置不能跑环任务");
							log.info(roleInfo.getRoleName() + "今天已经设置不能跑环任务");
							ScreenCapture.mouseClick(device, "1156 52");// 关闭包裹
							return false;
						}
						if(kong_location == 1){
							ScreenCapture.mouseClick(device, "810 402");
						}
						
						if(kong_location == 2){
							ScreenCapture.mouseClick(device, "910 402");
						}
						if(kong_location == 3){
							ScreenCapture.mouseClick(device, "998 402");
						}
						if(kong_location == 4){
							ScreenCapture.mouseClick(device, "1080 402");
						}
						if(kong_location == 5){
							ScreenCapture.mouseClick(device, "716 492");
						}
						
						ScreenCapture.snapshot(device, path, "screen.png");
						Thread.sleep(5 * 100L);
						ImageUtils.cutPNG(new FileInputStream(path + "screen.png"), new FileOutputStream(path + device + ".png"), 363,
								190, 153, 42);// y52 244 307
						String text2 = baiduOCR.generalBasic(path + device + ".png");// 33 535
						text2 = Optional.ofNullable(SysStaticPhData.PH_WQ_TO_CONVEN.get(text2)).orElse(text2);
						log.info("识别包裹物品："+text2);
						if(wp.equals(text2)){
							ScreenCapture.mouseClick(device, "1156 52");// 关闭包裹
							
							TaskInfo updateTask = taskInfoService.findByRoleIdAndTaskText(taskInfo.getRoleId(), taskInfo.getTaskText());
							if(updateTask != null){
							   updateTask.setStatus("1");
							   taskInfoService.saveAndFlush(updateTask);
							}
							break;
						}
						
					}
					
				}
			}
			
			}
		
		if(kong_location == 99){
			ScreenCapture.mouseClick(device, "1156 52");// 关闭包裹
		}
		
		if(kong_location == 0 && text.indexOf("帮") > -1 ){
			log.info("["+roleInfo.getRoleName()+"]空位满了");
			SpeechUtil.textToSpeech(roleInfo.getRoleName() + "空位满了");
			
			//EmailUtils emailUtils = new EmailUtils();
			//EmailContent content = new EmailContent("跑环报警", roleInfo.getRoleName() + "空位满了："+text);
	        //emailUtils.sendEmail(emailServerInfo, content);
			return false;
		}
		
		
		if(StringUtils.isNoneBlank(wp)){
			String[] c_k_x_y = SysStaticPhData.PH_WQ_TYPE.get(wp).split("&");
			log.info("获取物品价格："+roleInfo.getRemark2()+","+c_k_x_y[3]);
			PhGoodsPriceInfo phGoodsPriceInfo = phGoodsPriceInfoServce.findByServerNameAndGoodsType(roleInfo.getRemark2(), c_k_x_y[3]);
			TuInfoLog tuInfoLog = new TuInfoLog();
			tuInfoLog.setDevice(roleInfo.getDevice());
			tuInfoLog.setRoleName(roleInfo.getRoleName());
			tuInfoLog.setRemark(text);
			tuInfoLog.setPrice(phGoodsPriceInfo == null ? 0:phGoodsPriceInfo.getPrice());
			tuInfoLog.setCreateTime(new Date());
			tuInfoLogService.save(tuInfoLog);
		}
		
		
		//go npc 所在地图
		goToArea(roleInfo,path,addr_info,wp,npc_addr);

		
		// 点击任务追踪
		if(Integer.valueOf(addr_info[1]) > 1){
			Thread.sleep(1500L);
			ScreenCapture.mouseClick(device, "1430 287");
			Thread.sleep(1500L);
			if(StringUtils.isNoneBlank(wp)){
				ScreenCapture.mouseClick(device, "1015 122");//164
			}
			Thread.sleep(Integer.valueOf(addr_info[1]) * 1000L);
		}else{
			Thread.sleep(1 * 1000L);
		}
		
		if("1".equals(addr_info[2])){//需要走2段路
			ScreenCapture.mouseClick(device, info[4]+" "+info[5]);
			Thread.sleep(4 * 1000L);
		}
		
		if("穷汉".equals(npc) || "张老财".equals(npc)){
			//屏蔽按鈕
			ScreenCapture.mouseClick(device, "39 249");
			ImagePHash p = new ImagePHash();
			ScreenCapture.snapshot(device, path, "screen.png");
			ImageUtils.cutPNG(new FileInputStream(path + "screen.png"),
					new FileOutputStream(path + device + ".png"), 33, 453, 31, 56);
			String image1 = p.getHash(new FileInputStream(new File(path + device + ".png")));
			String image2 = p.getHash(new FileInputStream(new File(SysStaticData.SC_PIC_PATH + "tanwei.png")));
			int score = p.distance(image1, image2);
			if (score == 0 || score == 1 ) {
				// 屏蔽摊位
				ScreenCapture.mouseClick(device, "27 437");//
			}
	
		}
		
		//点击npc
		if(info.length == 2){
			ScreenCapture.mouseClick(device, info[0]+" "+info[1]);
		}
		
        if(info.length == 4 ){
        	ScreenCapture.mouseClick(device, info[2]+" "+info[3]);
		}
        
        if(info.length == 6 ){
        	ScreenCapture.mouseClick(device, info[2]+" "+info[3]);
		}
        
        if("穷汉".equals(npc) || "张老财".equals(npc)){
    		// 解除屏蔽
        	Thread.sleep(1 * 1000L);
    		ScreenCapture.mouseClick(device, "47 656");//
    	}
        
        //点击任务选择条件
        Thread.sleep(1 * 1000l);
        if("钟书生".equals(npc)
        		|| "美猴王".equals(npc)
        		|| "都市王".equals(npc)
        		|| "强盗头子".equals(npc)
        		|| "杨戬".equals(npc)
        		|| "太上老君".equals(npc)
        		|| "吴举人".equals(npc)
        		|| "吴举亼".equals(npc)){
        	 ScreenCapture.mouseClick(device, "1268 142");
        }else{
        	 ScreenCapture.mouseClick(device, "1256 259");
        }
        Thread.sleep(1 * 1000l);

        if(StringUtils.isNoneBlank(wp) ){
        	String[] c_k_x_y = SysStaticPhData.PH_WQ_TYPE.get(wp).split("&");
        	if("1".equals(c_k_x_y[2])){
        		if(kong_location == 1 || kong_location == 99){
            		ScreenCapture.mouseClick(device, "792 518");
            	}
            	if(kong_location == 2){
            		ScreenCapture.mouseClick(device, "874 518");
            	}
            	if(kong_location == 3){
            		ScreenCapture.mouseClick(device, "974 518");
            	}
            	if(kong_location == 4){
            		ScreenCapture.mouseClick(device, "1056 518");
            	}
        	}
        	
        	
        	 //确认
        	Thread.sleep(5 * 100l);
        	ScreenCapture.mouseClick(device, "399 630");
        }
        
        Thread.sleep(5 * 100l);
    	ScreenCapture.mouseClick(device, "710 603");
    	
    	
		return true;
	}
	
	private String getPhTaskInfo(RoleInfo roleInfo, String path) throws Exception {
		String device = roleInfo.getDevice();
		ScreenCapture.mouseClick(device, "1358 184");
		Thread.sleep(1 * 1000L);
		ScreenCapture.snapshot(device, path, "screen.png");
		Thread.sleep(5 * 100L);
		ImageUtils.cutPNG(new FileInputStream(path + "screen.png"), new FileOutputStream(path + device + ".png"), 506,
				122, 612, 100);// y52 244 307
		//ImageUtils.cutPNG(new FileInputStream(path + "screen.png"), new FileOutputStream(path + device + ".png"), 506,
		//		159, 612, 40);
		String text = baiduOCR.generalBasic(path + device + ".png");// 33 535
																	// 1317 620
		String npc = "";
		String wp = "";
		for (String key : SysStaticPhData.NPC.keySet()) {
			if(text.indexOf(key) > -1){
				npc = key;
				break;
			}
		}
		
        for (String key : SysStaticPhData.PH_WQ_TYPE.keySet()) {
        	if(text.indexOf(key) > -1){
        		wp = key;
				break;
			}
		}
        
      //===============高精度识别====================
      if(StringUtils.isBlank(npc)){
    	  text = baiduOCR.accurateBasic(path + device + ".png");	
      }
      
      if (text.indexOf("帮") > -1 
				&& text.indexOf("找") > -1
				&& StringUtils.isBlank(wp)) {
    	  text = baiduOCR.accurateBasic(path + device + ".png");	
      }
      //===============高精度识别====================
        
		ScreenCapture.mouseClick(device, "1138 61");
		
		String xiang_time = (String) redisService.get("xiang_time_ph"+roleInfo.getRoleId());
	    if (StringUtils.isEmpty(xiang_time)) {
			//使用摄药香
			ScreenCapture.mouseClick(device, "1308 675");// # 打开包裹
			ScreenCapture.mouseClick(device, "987 488");// # 
			ScreenCapture.mouseClick(device, "511 404");// # 
			ScreenCapture.mouseClick(device, "1156 52");// 关闭包裹
			redisService.set("xiang_time_ph"+roleInfo.getRoleId(), "xiang_time_ph",1500L);
		}
		return text;
	}
	
	private Integer getKongLocation(String device,String path,String wp) throws Exception{
		   ScreenCapture.snapshot(device,path, "screen.png");
		   ImageUtils.cutPNG(new FileInputStream(path +"screen.png"),
		               new FileOutputStream(path + device +".png"), 774,363, 73, 66);//第三排2个
			ImagePHash p = new ImagePHash();
			String image1 = p.getHash(new FileInputStream(new File(path + device + ".png")));
			String image2 = p.getHash(new FileInputStream(new File(SysStaticData.SC_PIC_PATH + "kong.png")));
			int score = p.distance(image1, image2);
			if(score < 8){
				return 1;
			}else{
				ScreenCapture.mouseClick(device, "815 402");
				
				ScreenCapture.snapshot(device, path, "screen.png");
				Thread.sleep(5 * 100L);
				ImageUtils.cutPNG(new FileInputStream(path + "screen.png"), new FileOutputStream(path + device + ".png"), 363,
						190, 153, 42);// y52 244 307
				String text2 = baiduOCR.generalBasic(path + device + ".png");// 33 535
				text2 = Optional.ofNullable(SysStaticPhData.PH_WQ_TO_CONVEN.get(text2)).orElse(text2);
				log.info("识别包裹物品："+text2);
				if(wp.equals(text2)){
					return 99;
				}
			}
			
			ImageUtils.cutPNG(new FileInputStream(path +"screen.png"),
		               new FileOutputStream(path + device +".png"), 864,363, 73, 66);//第三排2个
			String image3 = p.getHash(new FileInputStream(new File(path + device + ".png")));
			score = p.distance(image3, image2);
			if(score < 8){
				return 2;
			}
			
			ImageUtils.cutPNG(new FileInputStream(path +"screen.png"),
		               new FileOutputStream(path + device +".png"), 954,363, 73, 66);//第三排3个
			String image4 = p.getHash(new FileInputStream(new File(path + device + ".png")));
			score = p.distance(image4, image2);
			if(score < 8){
				return 3;
			}
			
			ImageUtils.cutPNG(new FileInputStream(path +"screen.png"),
		               new FileOutputStream(path + device +".png"), 1044,363, 73, 66);//第三排4个
			String image5 = p.getHash(new FileInputStream(new File(path + device + ".png")));
			score = p.distance(image5, image2);
			if(score < 8){
				return 4;
			}
			
			ImageUtils.cutPNG(new FileInputStream(path +"screen.png"),
		               new FileOutputStream(path + device +".png"), 684,453, 73, 66);//第四排1个
			String image6 = p.getHash(new FileInputStream(new File(path + device + ".png")));
			score = p.distance(image6, image2);
			if(score < 8){
				return 5;
			}
			
		   return 0;
	   }
	
	
	private boolean goToArea(RoleInfo roleInfo,
			String path,String[] addr_info ,
			String wp,String npc_addr) throws Exception{
		String last_area = (String)redisService.get("last_area");
		log.info("上一个地图：" + last_area);
		String[] ss = {"yg","tg","dtjw2","df"};
		List<String> areas = Arrays.asList(ss);
		
		if(addr_info[0].equals(last_area) 
				&& StringUtils.isBlank(wp)
				&& areas.contains(addr_info[0])){
			log.info("还在原地图找人");
			return true;
		}
		
		//回师门
		if(addr_info[0].equals(roleInfo.getRoleSect())){
			holdService.getServiceInstances(
					IGoToSectService.class).stream().filter(s -> s.support(roleInfo))
					.forEach(s -> s.goBackHome(roleInfo, path));
			return true;
		}
		
		//gonpc所在地图
		holdService.getServiceInstances(IGoAreaService.class).stream()
			        .filter(s -> s.support(addr_info[0]))
			        .forEach(s -> s.execute(roleInfo.getDevice(), path, npc_addr));
		
		redisService.set("last_area",addr_info[0],120L);
		return false;
	}
}
